package weibo4andriod.a;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.HttpURLConnection;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.GZIPInputStream;
import org.w3c.dom.Document;
import weibo4andriod.b.a.b;
import weibo4andriod.b.a.c;
import weibo4andriod.g;

public final class i
{
  private static final boolean a = weibo4andriod.a.r();
  private static ThreadLocal b = new j();
  private static Pattern i = Pattern.compile("&#([0-9]{3,5});");
  private int c;
  private Document d = null;
  private String e = null;
  private InputStream f;
  private HttpURLConnection g;
  private boolean h = false;

  public i()
  {
  }

  public i(HttpURLConnection paramHttpURLConnection)
  {
    this.g = paramHttpURLConnection;
    this.c = paramHttpURLConnection.getResponseCode();
    InputStream localInputStream = paramHttpURLConnection.getErrorStream();
    this.f = localInputStream;
    if (localInputStream == null)
      this.f = paramHttpURLConnection.getInputStream();
    if ((this.f == null) || (!("gzip".equals(paramHttpURLConnection.getContentEncoding()))))
      return;
    this.f = new GZIPInputStream(this.f);
  }

  private static String b(String paramString)
  {
    Matcher localMatcher = i.matcher(paramString);
    StringBuffer localStringBuffer = new StringBuffer();
    while (true)
    {
      if (!(localMatcher.find()))
      {
        localMatcher.appendTail(localStringBuffer);
        return localStringBuffer.toString();
      }
      localMatcher.appendReplacement(localStringBuffer, Character.toString((char)Integer.parseInt(localMatcher.group(1), 10)));
    }
  }

  public final String a()
  {
    if (this.e == null);
    label38: String str1;
    try
    {
      if (!(this.h))
        break label38;
      throw new IllegalStateException("Stream has already been consumed.");
    }
    catch (NullPointerException localNullPointerException)
    {
      throw new g(localNullPointerException.getMessage(), localNullPointerException);
      InputStream localInputStream = this.f;
      if (localInputStream == null)
      {
        str1 = null;
        break label226:
      }
      BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(localInputStream, "UTF-8"));
      StringBuffer localStringBuffer = new StringBuffer();
      String str2 = localBufferedReader.readLine();
      if (str2 == null)
      {
        this.e = localStringBuffer.toString();
        if (weibo4andriod.a.a())
          this.e = b(this.e);
        String str3 = this.e;
        if (a)
          System.out.println("[" + new Date() + "]" + str3);
        localInputStream.close();
        this.g.disconnect();
        this.h = true;
        str1 = this.e;
        break label226:
      }
      localStringBuffer.append(str2).append("\n");
    }
    catch (IOException localIOException)
    {
      throw new g(localIOException.getMessage(), localIOException);
    }
    label226: return str1;
  }

  public final String a(String paramString)
  {
    if (this.g != null);
    for (String str = this.g.getHeaderField(paramString); ; str = null)
      return str;
  }

  public final c b()
  {
    try
    {
      c localc = new c(a());
      return localc;
    }
    catch (b localb)
    {
      throw new g(localb.getMessage() + ":" + this.e, localb);
    }
  }

  public final weibo4andriod.b.a.a c()
  {
    try
    {
      weibo4andriod.b.a.a locala = new weibo4andriod.b.a.a(a());
      return locala;
    }
    catch (Exception localException)
    {
      throw new g(localException.getMessage() + ":" + this.e, localException);
    }
  }

  public final String toString()
  {
    if (this.e != null);
    for (String str = this.e; ; str = "Response{statusCode=" + this.c + ", response=" + this.d + ", responseString='" + this.e + '\'' + ", is=" + this.f + ", con=" + this.g + '}')
      return str;
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     weibo4andriod.a.i
 * JD-Core Version:    0.5.3
 */